#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

void process(vector<int> &nums, vector<vector<int>> &result, int j)
{
    if (j == nums.size())
    {
        result.push_back(nums);
    }
    for (int i = j; i < nums.size(); i++)
    {
        swap(nums[i], nums[j]);
        process(nums, result, j + 1);
        swap(nums[i], nums[j]);
    }
}

vector<vector<int>> _46(vector<int> nums)
{
    vector<vector<int>> result;
    process(nums, result, 0);
    return result;
}

int main()
{
    vector<int> v{1, 2, 3};
    vector<vector<int>> result;
    result = _46(v);
    for (size_t i = 0; i < result.size(); i++)
    {
        for (size_t j = 0; j < result[0].size(); j++)
        {
            cout << result[i][j] << " ";
        }
        cout << endl;
    }
}